from pydantic_settings import BaseSettings
from functools import lru_cache

# from test_localIP import get_local_ip


class Settings(BaseSettings):
    DEBUG_MODE: bool = False

    TITLE: str = "Linear Algebra API"
    DESCRIPTION: str = "Linear Algebra API"

    STATIC_DIR: str = "static"
    STATIC_URL: str = "/static"
    STATIC_NAME: str = "statics"

    TEMPLATES_DIR: str = "templates"

    LOG_PATH: str = "logs"
    LOG_ERROR_PATH: str = "logs/error.log"

    CORS_ALLOWED_ORIGINS: list[str] = ["*", "http://127.0.0.1:5500"]
    CORS_ALLOW_CREDENTIALS: bool = True
    CORS_ALLOW_METHODS: list[str] = ["*"]
    CORS_ALLOW_HEADERS: list[str] = ["*"]

    PROJECT_VERSION: str = "0.0.1"
    PROJECT_NAME: str = "Python Backend"
    PROJECT_DESCRIPTION: str = "Python Backend FRAMEWORK"

    VISIT_LIMIT_TIME: int = 3

    JWT_SECRET_KEY: str = "your-secret-key"
    JWT_ALGORITHM: str = "HS256"
    # JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 24*60
    JWT_ACCESS_TOKEN_EXPIRE_MINUTES: float = 0.4

    REDIS_POOL_HOST: str = "127.0.0.1"
    REDIS_POOL_PORT: str = "6379"
    REDIS_POOL_USER: str = ""
    REDIS_POOL_PASSWORD: str = ""
    REDIS_POOL_RESPONSES: bool = True
    REDIS_TTL: int = 10

    MYSQL_HOST: str = "127.0.0.1"
    MYSQL_PORT: str = "3306"
    MYSQL_USER: str = "root"
    MYSQL_PASSWORD: str = "ttt123"
    MYSQL_DATABASE: str = "test_dropboxdb"

    MAIL_USERNAME: str = "<EMAIL>"
    # MAIL_PASSWORD: str = "kxuryejwjomubdij"
    MAIL_PASSWORD: str = "zvifjievpkbrbaih"
    MAIL_SERVER: str = "smtp.qq.com"
    MAIL_FROM: str = "<EMAIL>"
    SEND_EMAIL_TO: str = "<EMAIL>"

    class Config:
        env_file = (".env", ".env.prod")
        # env_file = (".env")


@lru_cache()
def get_settings() -> Settings:
    return Settings()


config = get_settings()
